package com.jokelandave.poc.server.domain;

import javax.persistence.Id;

import com.googlecode.objectify.Key;

public class Bet {

	@Id
	Long id;
	
	Key<SportEvent> sportEvent;
	
	int amount;
	
	Key<Team> team;
	
	Key<Profile> profile;
	
	Bet()
	{
	}
	
	public Bet(Key<Profile> profile, Key<SportEvent> sportEvent, Key<Team> team, int amount)
	{
		this.profile = profile;
		this.sportEvent = sportEvent;
		this.team = team;
		this.amount = amount;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + amount;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((profile == null) ? 0 : profile.hashCode());
		result = prime * result
				+ ((sportEvent == null) ? 0 : sportEvent.hashCode());
		result = prime * result + ((team == null) ? 0 : team.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Bet other = (Bet) obj;
		if (amount != other.amount)
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (profile == null) {
			if (other.profile != null)
				return false;
		} else if (!profile.equals(other.profile))
			return false;
		if (sportEvent == null) {
			if (other.sportEvent != null)
				return false;
		} else if (!sportEvent.equals(other.sportEvent))
			return false;
		if (team == null) {
			if (other.team != null)
				return false;
		} else if (!team.equals(other.team))
			return false;
		return true;
	}

	public Long getId()
	{
		return id;
	}
	
	public Key<SportEvent> getSportEvent() {
		return sportEvent;
	}

	public void setSportEvent(Key<SportEvent> sportEvent) {
		this.sportEvent = sportEvent;
	}

	public int getAmount() {
		return amount;
	}

	public void setAmount(int amount) {
		this.amount = amount;
	}

	public Key<Team> getTeam() {
		return team;
	}

	public void setTeam(Key<Team> team) {
		this.team = team;
	}

	public Key<Profile> getProfile() {
		return profile;
	}

	public void setProfile(Key<Profile> profile) {
		this.profile = profile;
	}
	
}
